<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="灰度发布,流量控制," />










<meta name="description" content="背景及概述背景公司在去年上线了蓝绿发布，大家也摆脱了发版加班的苦恼，在日益业务增长的情况下，服务数和节点数不断增加，由于是蓝绿版本隔离的颗粒为整套环境，成本相对来说比较高，因此本次将设计灰度发布流程来实现降本增效的目的。将版本隔离的颗粒的缩小到某个服务某个节点。 灰度（染色）方案目标如下：  对测试环境进行逻辑隔离：减少硬件成本消耗、减少部署测试环境人力消耗、减少发布版后同步环境的人力消耗以及沟通">
<meta property="og:type" content="article">
<meta property="og:title" content="基于SpringCloud及Nacos灰度发布方案">
<meta property="og:url" content="http://yoursite.com/p/dc61be01.html">
<meta property="og:site_name" content="Molzhao">
<meta property="og:description" content="背景及概述背景公司在去年上线了蓝绿发布，大家也摆脱了发版加班的苦恼，在日益业务增长的情况下，服务数和节点数不断增加，由于是蓝绿版本隔离的颗粒为整套环境，成本相对来说比较高，因此本次将设计灰度发布流程来实现降本增效的目的。将版本隔离的颗粒的缩小到某个服务某个节点。 灰度（染色）方案目标如下：  对测试环境进行逻辑隔离：减少硬件成本消耗、减少部署测试环境人力消耗、减少发布版后同步环境的人力消耗以及沟通">
<meta property="og:image" content="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/%E7%81%B0%E5%BA%A6%E5%8A%9F%E8%83%BD%E6%B8%85%E5%8D%95.png">
<meta property="og:image" content="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/%E7%81%B0%E5%BA%A6%E5%8F%91%E5%B8%83%E6%95%B4%E4%BD%93%E8%AE%BE%E8%AE%A1.png">
<meta property="og:image" content="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/%E6%A8%AA%E5%90%91%E6%B5%81%E9%87%8F%E6%B3%B3%E9%81%93%E5%9B%BE.png">
<meta property="og:image" content="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/mq%E6%B5%81%E9%87%8F%E6%B3%B3%E9%81%93%E5%9B%BE.png">
<meta property="og:image" content="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/%E7%BB%9F%E4%B8%80%E8%A7%84%E5%88%99.png">
<meta property="og:image" content="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/deploy.png">
<meta property="og:image" content="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/%E4%B8%8A%E7%BA%BF%E6%96%B9%E6%A1%88.png">
<meta property="article:published_time" content="2023-03-17T05:51:00.000Z">
<meta property="article:modified_time" content="2023-04-09T09:17:43.167Z">
<meta property="article:author" content="MolZhao">
<meta property="article:tag" content="灰度发布">
<meta property="article:tag" content="流量控制">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/%E7%81%B0%E5%BA%A6%E5%8A%9F%E8%83%BD%E6%B8%85%E5%8D%95.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"我们没有找到任何搜索结果: ${query}","hits_stats":"找到约${hits}条结果 (用时 ${time}ms)"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/p/dc61be01.html"/>





  <title>基于SpringCloud及Nacos灰度发布方案 | Molzhao</title>
  








<meta name="generator" content="Hexo 4.2.1"></head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Molzhao</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/index.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/index.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/index.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404/index.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>

                

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/p/dc61be01.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="MolZhao">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Molzhao">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">基于SpringCloud及Nacos灰度发布方案</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2023-03-17T13:51:00+08:00">
                2023-03-17
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E4%BA%92%E8%81%94%E7%BD%91%E6%9E%B6%E6%9E%84/index.html" itemprop="url" rel="index">
                    <span itemprop="name">互联网架构</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/p/dc61be01.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/p/dc61be01.html" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o"></i> 阅读量
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  1.8k 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  6 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="背景及概述"><a href="#背景及概述" class="headerlink" title="背景及概述"></a>背景及概述</h2><h3 id="背景"><a href="#背景" class="headerlink" title="背景"></a>背景</h3><p>公司在去年上线了蓝绿发布，大家也摆脱了发版加班的苦恼，在日益业务增长的情况下，服务数和节点数不断增加，由于是蓝绿版本隔离的颗粒为整套环境，成本相对来说比较高，因此本次将设计灰度发布流程来实现降本增效的目的。将版本隔离的颗粒的缩小到某个服务某个节点。</p>
<p>灰度（染色）方案目标如下：</p>
<ol>
<li>对测试环境进行逻辑隔离：减少硬件成本消耗、减少部署测试环境人力消耗、减少发布版后同步环境的人力消耗以及沟通成本，提高测试环境的可维护性，提高测试环境的并行项目数，提高测试环境提早暴露问题的可能性。</li>
<li>平滑上线：可在真实的生产环境做最后的功能测试以及兼容性验证，并且可以通过服务上下线的方式平滑上线及回滚。</li>
<li>可进行A/BTest：打好公司进行数字化验证产品方案的基础，可以让不同用户体验不同版本，来分析哪个需求更加吸引用户使用。</li>
<li>多版本并行上线：提高团队整体上线效率，在生产环境无需进行串行化发布等待。</li>
<li>回收线上蓝绿一半资源：节省成本。</li>
<li>在健康业务试点并逐步展开，最终形成统一方案输出到全公司业务使用。</li>
</ol>
<h3 id="功能概述"><a href="#功能概述" class="headerlink" title="功能概述"></a>功能概述</h3><p>保证线上系统平稳的情况下，采用尽可能代码侵入性小的方案，进行根据特定参数以及特定规则进行单个服务单个节点的流量分配。</p>
<h3 id="需求点"><a href="#需求点" class="headerlink" title="需求点"></a>需求点</h3><p><img src="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/%E7%81%B0%E5%BA%A6%E5%8A%9F%E8%83%BD%E6%B8%85%E5%8D%95.png" alt="灰度发布功能清单"></p>
<h2 id="非功能性需求"><a href="#非功能性需求" class="headerlink" title="非功能性需求"></a>非功能性需求</h2><h3 id="扩展性"><a href="#扩展性" class="headerlink" title="扩展性"></a>扩展性</h3><p>通过SpringBoot Starter的方式实现可插拔插件使用，需要使用灰度的时候引入，提取关键版本选择策略及灰度上下文为core包，如后续具体集成其他框架如注册中心只需要新建starter实现服务发现接口即可。</p>
<p>通过适配器模式适配各框架服务实例对象，抽取灰度策略core</p>
<h3 id="可用性"><a href="#可用性" class="headerlink" title="可用性"></a>可用性</h3><p>保证每个服务必定有default的环境可用，当服务的所有基线版本不健康需要发送企业微信报警机器人，保证每次请求必定有响应。</p>
<h3 id="性能"><a href="#性能" class="headerlink" title="性能"></a>性能</h3><p>所有流量标记通过请求头传递，并维护在线程的Threadlocal中，新增逻辑均为内存操作，不影响原系统性能</p>
<h3 id="可测试性"><a href="#可测试性" class="headerlink" title="可测试性"></a>可测试性</h3><p>目前采用记录日志的方式展示整条请求链的版本访问链路，方便测试查看一条请求链分别请求了哪些版本，后续可支持根据requestId进行链路可视化</p>
<h2 id="整体设计"><a href="#整体设计" class="headerlink" title="整体设计"></a>整体设计</h2><p><img src="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/%E7%81%B0%E5%BA%A6%E5%8F%91%E5%B8%83%E6%95%B4%E4%BD%93%E8%AE%BE%E8%AE%A1.png" alt="灰度发布整体设计"></p>
<ul>
<li>基线版本：生产环境的最稳定版本，当没有灰度实例的时候默认访问基线版本，因此需要保证每个服务都有基线版本存活，需要做监控，当某个服务所有基线版本不健康的时候需要发送报警通知。</li>
<li>灰度版本：灰度发布版本，根据用户的属性经过负载均衡访问此版本，可用于测试，体验新功能使用。</li>
</ul>
<table>
<thead>
<tr>
<th>中间件</th>
<th>是否需要隔离</th>
<th>灰度影响及解决方案</th>
</tr>
</thead>
<tbody><tr>
<td>注册中心</td>
<td>&#10008;</td>
<td>无需处理，通过项目启动时候注入的元数据进行区分版本</td>
</tr>
<tr>
<td>配置中心(需要调研是否支持灰度)</td>
<td>&#10008;</td>
<td>无需处理，隔离维护性太差，改动老配置场景较少，需要开发考虑兼容性</td>
</tr>
<tr>
<td>Redis</td>
<td>&#10008;</td>
<td>无需处理，隔离维护性太差，大多缓存的Key和业务数据绑定，业务数据和用户数据绑定，灰度目前根据用户维护隔离一定程度上实现了隔离，若非业务数据的配置数据，应当考虑放入配置中心去</td>
</tr>
<tr>
<td>Mysql</td>
<td>&#10008;</td>
<td>无需处理，灰度即线上环境应当保证数据共用</td>
</tr>
<tr>
<td>Mongo</td>
<td>&#10008;</td>
<td>无需处理，灰度即线上环境应当保证数据共用</td>
</tr>
<tr>
<td>定时任务</td>
<td>&#10008;</td>
<td>保证生产定时任务全部走default版本，定时任务都是以接口的形式写在业务服务中，若有访问灰度的需求，如：需要测试，可配置灰度请求头访问定时任务接口</td>
</tr>
<tr>
<td>消息队列</td>
<td>&#10008;</td>
<td>通过Mq网络代理服务EventCenter，保证什么环境生产的消息就被什么环境消费，如灰度环境下线即表示已合入基线版本，即访问基线版本即可</td>
</tr>
</tbody></table>
<h2 id="存储设计"><a href="#存储设计" class="headerlink" title="存储设计"></a>存储设计</h2><p>使用TransmittableThreadLocal技术，保证父子线程间的灰度上线文传递</p>
<h2 id="各模块设计"><a href="#各模块设计" class="headerlink" title="各模块设计"></a>各模块设计</h2><h3 id="横向流量泳道图"><a href="#横向流量泳道图" class="headerlink" title="横向流量泳道图"></a>横向流量泳道图</h3><p><img src="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/%E6%A8%AA%E5%90%91%E6%B5%81%E9%87%8F%E6%B3%B3%E9%81%93%E5%9B%BE.png" alt="HTTP流量泳道图"></p>
<h3 id="消息队列流量泳道图"><a href="#消息队列流量泳道图" class="headerlink" title="消息队列流量泳道图"></a>消息队列流量泳道图</h3><p><img src="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/mq%E6%B5%81%E9%87%8F%E6%B3%B3%E9%81%93%E5%9B%BE.png" alt="消息队列流量泳道图"></p>
<h4 id="Event-Center服务"><a href="#Event-Center服务" class="headerlink" title="Event-Center服务"></a>Event-Center服务</h4><ol>
<li>Event-Center服务是一个网络代理服务，仅做调度，代理了MQ的流量，使得开发者无需关注mq的流量归属。正常consumer的逻辑中也会有远程调用。</li>
<li>Event-Center无需关注使用哪种Mq客户端，如Kafka、RocketMq只需要在服务中引入官方的客户端即可消费消息</li>
<li>加了中间代理层是否会影响性能？会轻微影响性能，但对于异步消息来说，性能不是瓶颈所在。</li>
<li>Event-Center会不会成为消费能力瓶颈？不会，以往的消费者都是绑定在业务进程中，消费能力受制于业务进程的消费者线程数，抽离出独立服务之后为无状态服务，当消费能力不足的时候可以横向扩展。当然如果某个消费者流量过高，如IM服务，可以独立出im-eventcenter服务进行水平扩展</li>
<li>Event-Center保证开发自己调试的时候，不会因业务服务被别人本地启动导致消息丢失，排查半天，一定程度上提高了工作效率。</li>
<li>Event-Center服务消费者调度统一处理，符合单一职责，可以做一些mq逻辑的统一处理，如日志统一打印等额外操作。使得功能更加内聚。</li>
<li>Event-Center并不适用于所有场景，改造成本相对比较大，但也是可以考虑的一种方案</li>
</ol>
<h3 id="统一规则入口"><a href="#统一规则入口" class="headerlink" title="统一规则入口"></a>统一规则入口</h3><p><img src="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/%E7%BB%9F%E4%B8%80%E8%A7%84%E5%88%99.png" alt="统一规则入口"></p>
<h2 id="CICD"><a href="#CICD" class="headerlink" title="CICD"></a>CICD</h2><p><img src="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/deploy.png" alt="CICD"></p>
<h2 id="上线方案"><a href="#上线方案" class="headerlink" title="上线方案"></a>上线方案</h2><p>V1 V2为当前蓝绿环境<br>beta1 beta2 为灰度版本</p>
<ol>
<li>生产假设V2为正式环境，保持V2版本流量不变，将灰度改造的项目发至V1环境并且全量发布default基线版本。</li>
<li>部署APISIX上线，更新upstream为V1的gateway</li>
<li>测试配置host文件，来测试V1环境的灰度版本，先将default版本基础功能进行回归测试</li>
<li>发布灰度的bete1版本服务，并配置一些用户到beta1、2、3环境，测试流量走向是否正常</li>
<li>测试完毕，结合Argo Rollout系统分析，晚上将ELB流量全量切入V1蓝绿环境，此时用户流量全部默认走基线版本，观察情况，蓝绿V2环境作为备份环境，如有大面积问题直接切入V2。若无则上线完毕</li>
</ol>
<p><img src="https://molzhao-pic.oss-cn-beijing.aliyuncs.com/2023/2023-03-17/%E4%B8%8A%E7%BA%BF%E6%96%B9%E6%A1%88.png" alt="上线方案"></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/%E7%81%B0%E5%BA%A6%E5%8F%91%E5%B8%83/index.html" rel="tag"># 灰度发布</a>
          
            <a href="/tags/%E6%B5%81%E9%87%8F%E6%8E%A7%E5%88%B6/index.html" rel="tag"># 流量控制</a>
          
        </div>
      

      
      
        <div class="post-widgets">
        

        

        
          
          <div id="needsharebutton-postbottom">
            <span class="btn">
              <i class="fa fa-share-alt" aria-hidden="true"></i>
            </span>
          </div>
        
        </div>
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/p/992995.html" rel="next" title="JMETER的使用方法">
                <i class="fa fa-chevron-left"></i> JMETER的使用方法
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/p/345f118d.html" rel="prev" title="Day1：Success in life">
                Day1：Success in life <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/avatar.jpg"
                alt="MolZhao" />
            
              <p class="site-author-name" itemprop="name">MolZhao</p>
              <p class="site-description motion-element" itemprop="description">沉淀</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/index.html">
              
                  <span class="site-state-item-count">54</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">16</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">30</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/normcorer" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:MolZhaovo@163.com" target="_blank" title="Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>Mail</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#背景及概述"><span class="nav-number">1.</span> <span class="nav-text">背景及概述</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#背景"><span class="nav-number">1.1.</span> <span class="nav-text">背景</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#功能概述"><span class="nav-number">1.2.</span> <span class="nav-text">功能概述</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#需求点"><span class="nav-number">1.3.</span> <span class="nav-text">需求点</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#非功能性需求"><span class="nav-number">2.</span> <span class="nav-text">非功能性需求</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#扩展性"><span class="nav-number">2.1.</span> <span class="nav-text">扩展性</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#可用性"><span class="nav-number">2.2.</span> <span class="nav-text">可用性</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#性能"><span class="nav-number">2.3.</span> <span class="nav-text">性能</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#可测试性"><span class="nav-number">2.4.</span> <span class="nav-text">可测试性</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#整体设计"><span class="nav-number">3.</span> <span class="nav-text">整体设计</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#存储设计"><span class="nav-number">4.</span> <span class="nav-text">存储设计</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#各模块设计"><span class="nav-number">5.</span> <span class="nav-text">各模块设计</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#横向流量泳道图"><span class="nav-number">5.1.</span> <span class="nav-text">横向流量泳道图</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#消息队列流量泳道图"><span class="nav-number">5.2.</span> <span class="nav-text">消息队列流量泳道图</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#Event-Center服务"><span class="nav-number">5.2.1.</span> <span class="nav-text">Event-Center服务</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#统一规则入口"><span class="nav-number">5.3.</span> <span class="nav-text">统一规则入口</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#CICD"><span class="nav-number">6.</span> <span class="nav-text">CICD</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#上线方案"><span class="nav-number">7.</span> <span class="nav-text">上线方案</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">MolZhao</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">ZYJ</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>






        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i> 访客数
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i> 总访问量
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    
      <div id="needsharebutton-float">
        <span class="btn">
          <i class="fa fa-share-alt" aria-hidden="true"></i>
        </span>
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  










  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script type="text/javascript" src="/js/src/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: false,
        notify: false,
        appId: '18BuKzLQMbUp8ECwDBiHu6Df-MdYXbMMI',
        appKey: 'xVTsu5pYLayqSvClr36TzcAH',
        placeholder: '(•̀へ•╮)',
        avatar:'identicon',
        guest_info:guest,
        pageSize:'10' || 10,
    });

    $('.vpower').html('');
  </script>



  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "./public/search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  
  
  
  <link rel="stylesheet" href="/lib/needsharebutton/needsharebutton.css">

  
  
  <script src="/lib/needsharebutton/needsharebutton.js"></script>

  <script>
    
      pbOptions = {};
      
          pbOptions.iconStyle = "default";
      
          pbOptions.boxForm = "horizontal";
      
          pbOptions.position = "bottomCenter";
      
          pbOptions.networks = "Weibo,Wechat,Douban,QQZone,Twitter,Facebook";
      
      new needShareButton('#needsharebutton-postbottom', pbOptions);
    
    
      flOptions = {};
      
          flOptions.iconStyle = "default";
      
          flOptions.boxForm = "horizontal";
      
          flOptions.position = "middleRight";
      
          flOptions.networks = "Weibo,Wechat,Douban,QQZone,Twitter,Facebook";
      
      new needShareButton('#needsharebutton-float', flOptions);
    
  </script>

  

  

  

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"scale":1,"hHeadPos":0.5,"vHeadPos":0.5,"jsonPath":"/live2dw/assets/assets/wanko.model.json"},"display":{"superSample":2,"width":150,"height":150,"position":"right","hOffset":30,"vOffset":20},"mobile":{"show":false,"scale":0.05},"react":{"opacityDefault":0.6,"opacityOnHover":0.2},"log":false});</script></body>
</html>
